#include "unp.h"

int Socket(int domain, int type, int protocol){
	int sockfd;
	if( (sockfd = socket(domain, type, protocol)) < 0)
		err_sys("socket error");
	return sockfd;
}

void Bind(int sockfd, const struct sockaddr* addr, socklen_t addrlen){
	if( bind(sockfd, addr, addrlen) < 0)
		err_sys("bind error");
}

void Listen(int sockfd, int backlog){
	if( listen(sockfd, backlog) < 0)
		err_sys("listen error");
}

int Accept(int sockfd, struct sockaddr* addr, socklen_t * addrlen){
	int ret;
	if( (ret = accept(sockfd, addr, addrlen)) < 0)
		err_sys("accept error");
	return ret;
}

void Connect(int sockfd, const struct sockaddr* addr, socklen_t addrlen){
	if( connect(sockfd, addr, addrlen) < 0)
		err_sys("connect error");
}

void Close(int fd){
	if( close(fd) < 0)
		err_sys("close error");
}

pid_t Fork(void){
	pid_t ret;
	if( (ret = fork()) < 0)
		err_sys("fork error");
	return ret;
}

